import { IniData } from './IniData';
import WXAPI from './WXApi';
import TTAPI from './TTApi';
import MZAPI from './MZApi';
import H5API from './H5Api';

export default class SdkFactory {
    public SdkAPI = null;

    // 接入的平台(wx:微信,tt: 字节跳动,mz：魅族, 'h5':web版本)
    private _platformCode = IniData.PLATFORMCODE;

    // 单例模式
    private static _instance: SdkFactory = null;
    public static getInstance() {
        if (this._instance == null) {
            this._instance = new SdkFactory();
        }
        return this._instance;
    }

    constructor() {
        switch (this._platformCode) {
            case 'wx':
                this.SdkAPI = WXAPI.getInstance();
                break;
            case 'tt':
                this.SdkAPI = TTAPI.getInstance();
                break;
            case 'mz':
                this.SdkAPI = MZAPI.getInstance();
                break;
            default:
                this.SdkAPI = H5API.getInstance();
                break;
        }
    }
}